﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media.Animation;
using System.ComponentModel;
using System.Windows.Controls;

namespace Vikipedia.CommonTools.Subtitles
{
    public  abstract class SubtitleProjectionist:DependencyObject 
    {
        public static readonly PropertyMetadata defaultMetadata = new PropertyMetadata();
        public static readonly DependencyProperty PositionProperty = 
            DependencyProperty.Register(
                    "Position", 
                    typeof(TimeSpan), 
                    typeof(SubtitleProjectionist), 
                    new PropertyMetadata
                        (
                            TimeSpan.Zero ,
                            new PropertyChangedCallback(SubtitleProjectionist_PositionChangedFunction)
                        )
                );
        public static readonly DependencyProperty TargetProperty =
            DependencyProperty.RegisterAttached("Target", typeof(Panel), typeof(SubtitleProjectionist), defaultMetadata);

        public static readonly DependencyProperty SubtitleSourceProperty =
            DependencyProperty.RegisterAttached("SubtitleSource", typeof(IList<ISubtitleItem>), typeof(SubtitleProjectionist), defaultMetadata);

        private static void SubtitleProjectionist_PositionChangedFunction(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((SubtitleProjectionist)d).PositionChanged((TimeSpan)e.NewValue);
        }


        protected abstract void PositionChanged(TimeSpan position);
        

        public Panel Target 
        { 
            get 
            {
                return (Panel)GetValue(TargetProperty);
            } 
            set 
            {
                SetValue(TargetProperty, value);

            } 
        }

        public TimeSpan Position
        {
            get
            {
                return (TimeSpan)GetValue(PositionProperty);
            }
            set
            {
                SetValue(PositionProperty, value);

            }
        }
        public IList<ISubtitleItem> SubtitleSource 
        {
            get
            {
                return (IList<ISubtitleItem>)GetValue(SubtitleSourceProperty);
            }
            set
            {
                SetValue(SubtitleSourceProperty, value);

            } 
        }




 


    }
}
